import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const store = new Vuex.Store({
	state: {
		userName: '',
		isLogin: uni.getStorageSync('token') ? true : false 
	},
	getters:{
		getUserName:(state) => {
			return state.userName
		}
	},
	mutations: {
		setUsername(state,name){
			state.userName = name;
		},
		logOut(state){
			state.userName = '',
			state.isLogin = false;
		}
	}
});

export default store;